package mqs

import (
	"context"
	"encoding/json"
	"github.com/streadway/amqp"
)

func EncodeJSONResponse(
	ctx context.Context,
	pub *amqp.Publishing,
	response interface{},
) error {
	if response == nil {
		return nil
	}
	b, err := json.Marshal(response)
	if err != nil {
		return err
	}
	pub.Body = b
	return nil
}
